import inspect
from typing import Any

from common.base.base_api import BaseApi
from .schemas.dsp_telemetry import DspTelemetry
from .schemas.gps_telemetry import GpsTelemetry
from .schemas.pwr_telemetry import PwrTelemetry
from .schemas.sfp_telemetry import SfpTelemetry
from settings import settings


class TelemetryApi(BaseApi):
    __slots__ = []

    def __init__(self):
        super(TelemetryApi, self).__init__(request_queue_uuid=settings.TELEMETRY_REQUEST_QUEUE)

    async def get_gps_telemetry(self) -> GpsTelemetry | None:
        return await self.send_rpc_request_message(
            inspect.currentframe().f_code.co_name,
            handle_result=lambda r: GpsTelemetry(**r)
        )

    async def get_dsp_telemetry(self) -> DspTelemetry | None:
        return await self.send_rpc_request_message(
            inspect.currentframe().f_code.co_name,
            handle_result=lambda r: DspTelemetry(**r)
        )

    async def get_pwr_telemetry(self) -> PwrTelemetry | None:
        return await self.send_rpc_request_message(
            inspect.currentframe().f_code.co_name,
            handle_result=lambda r: PwrTelemetry(**r)
        )

    async def get_sfp_telemetry(self) -> SfpTelemetry | None:
        return await self.send_rpc_request_message(
            inspect.currentframe().f_code.co_name,
            handle_result=lambda r: SfpTelemetry(**r)
        )

    async def get_numSV_telemetry(self) -> int | None:
        return await self.send_rpc_request_message(
            inspect.currentframe().f_code.co_name
        )
